<?php
require_once('controller/auth.php');
//Start session
@session_start();

//Include database connection details
require_once('controller/inc/config.inc');

//Array to store validation errors
$errmsg_arr = array();

//Validation error flag
$errflag = false;

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<title>Project Tracking MIS</title>

<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!-- Le styles -->
<link rel="stylesheet" href="assets/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="assets/css/bootstrap-responsive.css"
	type="text/css" />
<link rel="stylesheet" href="assets/css/font-awesome.css"
	type="text/css" />
<script type="text/javascript" src="assets/js/jquery.min.js"></script>

<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-popover.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-tooltip.js"></script>
<script>
$(function ()
{ 
$("input").popover({trigger: 'focus', 'placement':'right'});

$("textarea").popover({trigger: 'focus'});


$('#tab').tooltip({'placement':'right', 'trigger' : 'hover'});

$('a').tooltip({'placement':'bottom', 'trigger' : 'hover'});	
});
</script>

<style>
body {
	padding-top: 60px;
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}

.dropdown-menu .sub-menu {
	left: 100%;
	position: absolute;
	top: 0;
	visibility: hidden;
	margin-top: -1px;
}

.dropdown-menu li:hover .sub-menu {
	visibility: visible;
	display: block;
}

.navbar .sub-menu:before {
	border-bottom: 7px solid transparent;
	border-left: none;
	border-right: 7px solid rgba(0, 0, 0, 0.2);
	border-top: 7px solid transparent;
	left: -7px;
	top: 10px;
}

.navbar .sub-menu:after {
	border-top: 6px solid transparent;
	border-left: none;
	border-right: 6px solid #fff;
	border-bottom: 6px solid transparent;
	left: 10px;
	top: 11px;
	left: -6px;
}
</style>
<!-- Le fav and touch icons -->

</head>

<body>
<div class="container-fluid"><!--TOp Nav-->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid"><a data-target=".nav-collapse"
	data-toggle="collapse" class="btn btn-navbar"> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a
	href="#" class="brand">TMIS | Project Tracking</a>
<div class="nav-collapse">
<ul class="nav">
	<li class="active"><a href="dashboard.php">Home Page</a></li>
	<li><a href="create_project.php">Create Project</a></li>
	<li><a href="update_project.php">Update Project</a></li>
	<li><a href="reports.php">Reports</a></li>

</ul>
<form action="" class="navbar-search pull-left">
<input type="text" placeholder="Search" class="search-query span2">

</form>
<ul class="nav pull-right">


	<div class="pull-right">
	<ul class="nav pull-right">
		<li class="dropdown"><a href="#" class="dropdown-toggle"
			data-toggle="dropdown">Welcome, <?php echo $_SESSION['SESS_FIRST_NAME'] . " " . $_SESSION['SESS_LAST_NAME'];?>
		<b class="caret"></b></a>
		<ul class="dropdown-menu">
			<li><a href="/user/preferences"><i class="icon-cog"></i> Preferences</a></li>
			<li><a href="/help/support"><i class="icon-envelope"></i> Contact
			Support</a></li>
			<li class="divider"></li>
			<li><a href="controller/logout.php"><i class="icon-off"></i> Logout</a></li>
		</ul>
		</li>
	</ul>
	</div>


</ul>
</div>
<!-- /.nav-collapse --></div>
</div>
</div>


<script>
$(document).ready(function()
{
  //Handles menu drop down
  $('.dropdown-menu').find('form').click(function (e) {
        e.stopPropagation();
        });
  });
</script> <script type="text/javascript">
$(function() {
	//call the function onload
	getdata( 1 );
});

function getdata( pageno ){                     
	var targetURL = 'pagination/search_results.php?page=' + pageno;   

	$('#retrieved-data').html('<p><img src="pagination/ajax-loader.gif" /></p>');        
	$('#retrieved-data').load( targetURL ).hide().fadeIn('slow');
}      
</script> <!--/Top Nav-->
<div class="row-fluid">

<div class="span12"><!--Content--> <?php 
$serial=$_GET['id'];
$select_proj=mysql_query("SELECT * FROM main WHERE serial='$serial'");
$row_proj=mysql_fetch_array($select_proj);
$status=$row_proj['status'];
	$progress=0;
	switch($status){
	case 0:
	$status='Initiated';
	$progress="<div class='bar' style='width: 10%;' rel='tooltip' title='The overall progress of project is 10%!' data-placement='top'></div>";
	break;
	case 1:
	$status='Approved by MoE';
	$progress="<div class='bar' style='width: 30%;' rel='tooltip' title='The overall progress of project is 30%!' data-placement='top'></div>";
	break;
	case 2:
	$status='Budget Allocated';
	$progress="<div class='bar' style='width: 50%;' rel='tooltip' title='The overall progress of project is 50%!' data-placement='top'></div>";
	break;
	
	case 3:
	$status='Allotment Received';
	$progress="<div class='bar' style='width: 80%;' rel='tooltip' title='The overall progress of project is 80%!' data-placement='top'></div>";
	break;
	
	case 4:
	$status='Done';
	$progress="<div class='bar bar-success' style='width: 100%;' rel='tooltip' title='Good Job, the overall progress of project is 100%!' data-placement='top'></div>";
	break;
	
	default:
	$status='Undefined!';
	}
?>
<h2 class='text-info'>Details for: <span class='muted'><?php echo $row_proj['proj_name']; ?></span></h2>
<div><a href='javascript:history.back()' class='btn'>Back to Main List</a></div>
<br />
<div class='pull-right'><a href='update.php?id=<?php echo $row_proj['serial'];?>' class='btn btn-warning btn-small'><i
	class='icon-edit'></i>&nbsp;Update</a>&nbsp;
	<?php 
	if($row_proj['status']==4){
	?>
	<a href=''
	class='btn btn-success btn-small disabled'><i class='icon-ok'></i>&nbsp;Mark it Done</a>	
	<?php 
	}
	else {
	?>
	<a href=''
	class='btn btn-success btn-small'><i class='icon-ok'></i>&nbsp;Mark it Done</a>
	<?php } ?>
	</div>
<br />

<table class="table table-bordered">
	<tr>
		<th>Project Number</th>
		<th>Project Name</th>
		<th>Amount</th>
		<th>Submited By</th>
		<th>File Location</th>
		<th>Project Status</th>
		
		
	</tr>

	<tr>
		<td><?php echo $row_proj['request_no'];?></td>
		<td><?php echo $row_proj['proj_name']; ?></td>
		<td><?php echo $row_proj['amount']; ?></td>
		<td><?php echo $row_proj['submitted_by']; ?></td>
		<td><?php echo $row_proj['file_location']; ?></td>
		<?php
		$pre_date=$row_proj['prepared_date'];
		list ($year,$month,$day)=explode('-', $pre_date);
		$est_days=$row_proj['est_day_ted'];
		$exp_date=date('Y-m-d', mktime(0, 0, 0, $month, $day + $est_days, $year));;
		echo $exp_date;

		?>
		

		<?php
		$current_date=date('Y-m-d');

		?>
		<td><?php echo $status; ?></td>
		
		
		
	</tr>
	</div>

</table>
<h4>Detailed Dates</h4>
<table class='table table-striped'>
<tr>
<th>Prepared Date</th>
<th>Expired Date in TED</th>
<th>Submission Date to MoE</th>
<th>Date Approved by MoE</th>
<th>Submission Date to MoE Finance</th>
<th>Received Date from MoE Finance</th>
<th>Accept | Reject By MoE Finance</th>
<th>Submission Date to MoF</th>
<th>Check Issue Date</th>
</tr>
<td><?php echo $row_proj['prepared_date']; ?></td>
<td><?php echo $exp_date; ?></td>
<td><?php echo $row_proj['submission_moe_date']; ?></td>
<td><?php echo $row_proj['approve_moe_date']; ?></td>
<td><?php echo $row_proj['submission_moe_finance_date']; ?></td>
<td><?php echo $row_proj['received_moe_finace_date']; ?></td>
<td><?php echo $row_proj['accept_reject']; ?></td>
<td><?php echo $row_proj['submission_mof_date']; ?></td>
<td><?php echo $row_proj['cheque_issue_date']; ?></td>
<tr>

</tr>
</table>
<div  class='well well-small'>
<h3>Project Description</h3>
<p><?php echo $row_proj['description']; ?></p>
<h4>Remarks</h4>
<p><?php echo $row_proj['remarks']; ?></p>

		<div class="progress progress-striped">
		<?php echo $progress; ?>
		</div>
</div>
<!--/Content--></div>



</div>
<hr />
<footer class="footer"> &copy;2013 TMIS, TED, MoE </footer></div>

</body>

</html>
